package com.ruandi.bean;

import java.math.BigDecimal;

public class Rectangle {
    private BigDecimal length;
    private BigDecimal width;

    public Rectangle() {
    }

    public Rectangle(BigDecimal length, BigDecimal width) {
        this.length = length;
        this.width = width;
    }

    public BigDecimal getLength() {
        return length;
    }

    public void setLength(BigDecimal length) {
        this.length = length;
    }

    public BigDecimal getWidth() {
        return width;
    }

    public void setWidth(BigDecimal width) {
        this.width = width;
    }

    public BigDecimal getArea() {
        return ((length.divide(new BigDecimal("1"),1,BigDecimal.ROUND_UP)).multiply(width.divide(new BigDecimal("1"),1,BigDecimal.ROUND_UP))).divide(new BigDecimal("1"),1,BigDecimal.ROUND_HALF_UP);
    }

    public BigDecimal getPerimeter() {
        return (new BigDecimal("2").multiply(length.add(width))).divide(new BigDecimal("1"),1,BigDecimal.ROUND_HALF_UP);
    }

    public void getInfo() {
        System.out.println("长:" + length.divide(new BigDecimal("1"),1,BigDecimal.ROUND_UP)+ ",宽：" + width.divide(new BigDecimal("1"),1,BigDecimal.ROUND_UP) + ",面积：" + getArea() + ",周长：" + getPerimeter());
    }
    //public String getInfo(){
    //		return "长：" + length + "，宽：" + width + "，面积：" + getArea() + "，周长：" + getPerimeter();
    //	}
}
